better error message for user when deleting local items
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 4 Apr 2025 14:37:47 +0000 (16:37 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 7 Apr 2025 10:53:38 +0000 (10:53 +0000)
we might be displaying too technical errors that the user will have no
way to understand

for example on macOS, we might be getting:
Unknown error: 513

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/propagatorjobs.cpp
src/libsync/propagatorjobs.h

index a443d84547988323c51a23afa7858fd3917f1b4b..86086c3357e14e823f863e1767179a6a0312c347 100644 (file)
@@ -58,18 +58,15 @@ QByteArray localFileIdFromFullId(const QByteArray &id)
 bool PropagateLocalRemove::removeRecursively(const QString &path)
 {
     QString absolute = propagator()->fullLocalPath(_item->_file + path);
-    QStringList errors;
     QList<QPair<QString, bool>> deleted;
     const auto fileInfo = QFileInfo{absolute};
     const auto parentFolderPath = fileInfo.dir().absolutePath();
     const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
-    bool success = FileSystem::removeRecursively(
-        absolute,
-        [&deleted](const QString &path, bool isDir) {
-            // by prepending, a folder deletion may be followed by content deletions
-            deleted.prepend(qMakePair(path, isDir));
-        },
-        &errors);
+    const auto success = FileSystem::removeRecursively(absolute,
+                                                       [&deleted](const QString &path, bool isDir) {
+                                                           // by prepending, a folder deletion may be followed by content deletions
+                                                           deleted.prepend(qMakePair(path, isDir));
+                                                       });
 
     if (!success) {
         // We need to delete the entries from the database now from the deleted vector.
@@ -87,8 +84,6 @@ bool PropagateLocalRemove::removeRecursively(const QString &path)
                 qCWarning(lcPropagateLocalRemove) << "Failed to delete file record from local DB" << it.first.mid(propagator()->localPath().size());
             }
         }
-
-        _error = errors.join(", ");
     }
     return success;
 }
@@ -116,13 +111,13 @@ void PropagateLocalRemove::start()
     if (_moveToTrash && propagator()->syncOptions()._vfs->mode() != OCC::Vfs::WindowsCfApi) {
         if ((QDir(filename).exists() || FileSystem::fileExists(filename))
             && !FileSystem::moveToTrash(filename, &removeError)) {
-            done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);
+            done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError);
             return;
         }
     } else {
         if (_item->isDirectory()) {
             if (QDir(filename).exists() && !removeRecursively(QString())) {
-                done(SyncFileItem::NormalError, _error, ErrorCategory::GenericError);
+                done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError);
                 return;
             }
         } else {
@@ -133,7 +128,7 @@ void PropagateLocalRemove::start()
                 const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
 
                 if (!FileSystem::remove(filename, &removeError)) {
-                    done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);
+                    done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError);
                     return;
                 }
             }
index d5e2148c15c428190fb05516e78e27d9d78d435c..c7436b00a565d24500267f9276e414ac867f2a5f 100644 (file)
@@ -44,7 +44,7 @@ public:
 
 private:
     bool removeRecursively(const QString &path);
-    QString _error;
+
     bool _moveToTrash = false;
 };